
package com.noah.project.dao

import com.noah.project.model.About
import org.apache.ibatis.annotations.*
import org.springframework.stereotype.Repository

@Repository
interface AboutDao {
    @Insert("INSERT INTO about (aid, uid, alias, name, gender, age, head, email, phone, address, place, experience, education, profession, add1, addmsg1, add2, addmsg2, add3, addmsg3, createTime) " +
            "VALUES(#{aid}, #{uid}, #{alias}, #{name}, #{gender}, #{age}, #{head}, #{email}, #{phone}, #{address}, #{place}, #{experience}, #{education}, #{profession}, #{add1}, #{addmsg1}, #{add2}, #{addmsg2}, #{add3}, #{addmsg3}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "aid", keyColumn = "aid")//可以返回当前的uid,不加这行返回的是插入的行数
    fun insert(note: About): Long

    @Delete("DELETE FROM about WHERE aid =#{aid}")
    fun delete(aid: Long?): Long

    @Update("UPDATE about SET " +
            "name = #{name}, " +
            "alias = #{alias}, " +
            "gender = #{gender}, " +
            "age = #{age}, " +
            "head = #{head}, " +
            "email = #{email}, " +
            "phone = #{phone}, " +
            "address = #{address}, " +
            "place = #{place}, " +
            "experience = #{experience}, " +
            "education = #{education}, " +
            "profession = #{profession}, " +
            "add1 = #{add1}, " +
            "addmsg1 = #{addmsg1}, " +
            "add2 = #{add2}, " +
            "addmsg2 = #{addmsg2}, " +
            "add3 = #{add3}, " +
            "addmsg3 = #{addmsg3} " +
            "WHERE aid = #{aid}")
    fun update(note: About): Long

    @Select("SELECT * FROM about WHERE aid = #{aid}")
    fun findById(aid: Long?): About?

    @Select("SELECT * FROM about WHERE alias = #{alias}")
    fun findByAlias(alias: String?): About?

    @Select("SELECT * FROM about WHERE uid = #{uid}")
    fun findAbouts(uid: Long?): List<About>
}
